package ai.zixing.singleton;

/**
 * 懒汉式
 *  特点：延迟加载，只有在调用的时候才会创建对象
 */
public class Singleton_02 {

    private Singleton_02() {
    }

    private static Singleton_02 instance;

    /**
     * 通过判断对象是否被初始化，来选择是否创建对象
     */
    public static Singleton_02 getInstance() {
        if (instance == null) {
            instance = new Singleton_02();
        }
        return instance;
    }
}
